﻿using System;
using System.Collections.Generic;
using System.Text;
using Itdavany.Utility;
using Itdavany.Data;

namespace RollingKitty
{
    public static class AudioHelper
    {
        static SoundObject bgmtrack;
        static bool loop = false;

        public static void PlayBGM(SoundObject obj)
        {
            PlayBGM(obj, true);
        }

        public static void PlayBGM(SoundObject obj, bool looping)
        {
            if (bgmtrack != null) bgmtrack.Stop();

            bgmtrack = obj;

            if (bgmtrack != null) bgmtrack.Play();

            loop = looping;
        }

        public static void Update()
        {
            if (loop && bgmtrack != null && !bgmtrack.IsPlaying) bgmtrack.Play();
        }

        static SoundObject effect;
        public static void SetEffect(SoundObject obj) 
        {
            effect = obj;
        }

        public static void OnEffect(object obj, EventArgs arg)
        {
            if (effect != null)
                effect.Play();
        }

        public static void PlayEffect()
        {
            OnEffect(null, EventArgs.Empty);
        }
    }
}
